function.js ➔ select   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
/**
2
 * Generate a new password, which may then be copied to the form
3
 * with suggestPasswordCopy().
4
 *
5
 * @param   string   the form name
0 ignored issues
show
Documentation introduced by
The parameter string does not exist. Did you maybe forget to remove this comment?
Loading history...
6
 *
7
 * @return  boolean  always true
8
 */
9
function suggestPassword() {
10
    // restrict the password to just letters and numbers to avoid problems:
11
    // "editors and viewers regard the password as multiple words and
12
    // things like double click no longer work"
13
    var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ";
14
    var passwordlength = 16;    // do we want that to be dynamic?  no, keep it simple :)
15
    var passwd = document.getElementById('generated_pw');
16
    passwd.value = '';
17
18
    for ( i = 0; i < passwordlength; i++ ) {
0 ignored issues
show
Bug introduced by
The variable i seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.i.
Loading history...
19
        passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
20
    }
21
    return passwd.value;
22
}
23
24
25
/**
26
 * Copy the generated password (or anything in the field) to the form
27
 *
28
 * @param   string   the form name
0 ignored issues
show
Documentation introduced by
The parameter string does not exist. Did you maybe forget to remove this comment?
Loading history...
29
 *
30
 * @return  boolean  always true
31
 */
32
function suggestPasswordCopy() {
33
    document.getElementById('text_pma_pw').value = document.getElementById('generated_pw').value;
34
    document.getElementById('text_pma_pw2').value = document.getElementById('generated_pw').value;
35
    return true;
36
}
37
38
/**
39
 * Opens calendar window.
40
 *
41
 * @param   string      calendar.php parameters
0 ignored issues
show
Documentation introduced by
The parameter string does not exist. Did you maybe forget to remove this comment?
Loading history...
42
 * @param   string      form name
0 ignored issues
show
Documentation introduced by
The parameter string has already been documented on line 41. The second definition is ignored.
Loading history...
43
 * @param   string      field name
0 ignored issues
show
Documentation introduced by
The parameter string has already been documented on line 41. The second definition is ignored.
Loading history...
44
 * @param   string      edit type - date/timestamp
0 ignored issues
show
Documentation introduced by
The parameter string has already been documented on line 41. The second definition is ignored.
Loading history...
45
 */
46
function openCalendar(params, form, field, type) {
47
    window.open("../calendar/mini_calendar.php?" + params, "calendar", "width=400,height=200,status=yes");
48
    dateField = eval("document." + form + "." + field);
0 ignored issues
show
Bug introduced by
The variable dateField seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dateField.
Loading history...
Security Performance introduced by
Calls to eval are slow and potentially dangerous, especially on untrusted code. Please consider whether there is another way to achieve your goal.
Loading history...
49
    dateType = type;
0 ignored issues
show
Bug introduced by
The variable dateType seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dateType.
Loading history...
50
}
51
52
/**
53
 * Formats number to two digits.
54
 *
55
 * @param   int number to format.
0 ignored issues
show
Documentation introduced by
The parameter int does not exist. Did you maybe forget to remove this comment?
Loading history...
56
 * @param   string type of number
0 ignored issues
show
Documentation introduced by
The parameter string does not exist. Did you maybe forget to remove this comment?
Loading history...
57
 */
58
function formatNum2(i, valtype) {
59
    f = (i < 10 ? '0' : '') + i;
0 ignored issues
show
Bug introduced by
The variable f seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.f.
Loading history...
60
    if (valtype && valtype != '') {
61
        switch(valtype) {
62
            case 'month':
63
                f = (f > 12 ? 12 : f);
64
                break;
65
66
            case 'day':
67
                f = (f > 31 ? 31 : f);
68
                break;
69
70
            case 'hour':
71
                f = (f > 24 ? 24 : f);
72
                break;
73
74
            default:
0 ignored issues
show
Coding Style Comprehensibility introduced by
The default case is not the last statement in this switch statement. For the sake of readability, you might want to move it to the end of the statement.
Loading history...
75
            case 'second':
76
            case 'minute':
77
                f = (f > 59 ? 59 : f);
78
                break;
79
        }
80
    }
81
82
    return f;
83
}
84
85
/**
86
 * Formats number to two digits.
87
 *
88
 * @param   int number to format.
0 ignored issues
show
Documentation introduced by
The parameter int does not exist. Did you maybe forget to remove this comment?
Loading history...
89
 * @param   int default value
0 ignored issues
show
Documentation introduced by
The parameter int has already been documented on line 88. The second definition is ignored.
Loading history...
90
 * @param   string type of number
0 ignored issues
show
Documentation introduced by
The parameter string does not exist. Did you maybe forget to remove this comment?
Loading history...
91
 */
92
function formatNum2d(i, default_v, valtype) {
93
    i = parseInt(i, 10);
94
    if (isNaN(i)) return default_v;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
95
    return formatNum2(i, valtype)
96
}
97
98
/**
99
 * Formats number to four digits.
100
 *
101
 * @param   int number to format.
0 ignored issues
show
Documentation introduced by
The parameter int does not exist. Did you maybe forget to remove this comment?
Loading history...
102
 */
103
function formatNum4(i) {
104
    i = parseInt(i, 10)
105
    return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i;
106
}
107
108
/**
109
 * Initializes calendar window.
110
 */
111
function initCalendar() {
112
    if (!year && !month && !day) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable month is declared in the current environment, consider using typeof month === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
Best Practice introduced by
If you intend to check if the variable year is declared in the current environment, consider using typeof year === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
Best Practice introduced by
If you intend to check if the variable day is declared in the current environment, consider using typeof day === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
113
        /* Called for first time */
114
        if (window.opener.dateField.value) {
115
            value = window.opener.dateField.value;
0 ignored issues
show
Bug introduced by
The variable value seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.value.
Loading history...
116
            if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
117
                if (window.opener.dateType == 'datetime') {
118
                    parts   = value.split(' ');
0 ignored issues
show
Bug introduced by
The variable parts seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.parts.
Loading history...
119
                    value   = parts[0];
120
121
                    if (parts[1]) {
122
                        time    = parts[1].split(':');
0 ignored issues
show
Bug introduced by
The variable time seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.time.
Loading history...
123
                        hour    = parseInt(time[0],10);
0 ignored issues
show
Bug introduced by
The variable hour seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.hour.
Loading history...
124
                        minute  = parseInt(time[1],10);
0 ignored issues
show
Bug introduced by
The variable minute seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.minute.
Loading history...
125
                        second  = parseInt(time[2],10);
0 ignored issues
show
Bug introduced by
The variable second seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.second.
Loading history...
126
                    }
127
                }
128
                date        = value.split("-");
0 ignored issues
show
Bug introduced by
The variable date seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.date.
Loading history...
129
                day         = parseInt(date[2],10);
0 ignored issues
show
Bug introduced by
The variable day seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.day.
Loading history...
130
                month       = parseInt(date[1],10) - 1;
0 ignored issues
show
Bug introduced by
The variable month seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.month.
Loading history...
131
                year        = parseInt(date[0],10);
0 ignored issues
show
Bug introduced by
The variable year seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.year.
Loading history...
132
            } else {
133
                year        = parseInt(value.substr(0,4),10);
134
                month       = parseInt(value.substr(4,2),10) - 1;
135
                day         = parseInt(value.substr(6,2),10);
136
                hour        = parseInt(value.substr(8,2),10);
137
                minute      = parseInt(value.substr(10,2),10);
138
                second      = parseInt(value.substr(12,2),10);
139
            }
140
        }
141
        if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) {
0 ignored issues
show
Bug introduced by
The variable year does not seem to be initialized in case window.opener.dateField.value on line 114 is false. Are you sure the function isNaN handles undefined variables?
Loading history...
Bug introduced by
The variable day does not seem to be initialized in case window.opener.dateField.value on line 114 is false. Are you sure the function isNaN handles undefined variables?
Loading history...
Bug introduced by
The variable month does not seem to be initialized in case window.opener.dateField.value on line 114 is false. Are you sure the function isNaN handles undefined variables?
Loading history...
142
            dt      = new Date();
0 ignored issues
show
Bug introduced by
The variable dt seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dt.
Loading history...
143
            year    = dt.getFullYear();
144
            month   = dt.getMonth();
145
            day     = dt.getDate();
146
        }
147
        if (isNaN(hour) || isNaN(minute) || isNaN(second)) {
0 ignored issues
show
Bug introduced by
The variable second seems to not be initialized for all possible execution paths. Are you sure isNaN handles undefined variables?
Loading history...
Bug introduced by
The variable minute seems to not be initialized for all possible execution paths. Are you sure isNaN handles undefined variables?
Loading history...
Bug introduced by
The variable hour seems to not be initialized for all possible execution paths. Are you sure isNaN handles undefined variables?
Loading history...
148
            dt      = new Date();
149
            hour    = dt.getHours();
150
            minute  = dt.getMinutes();
151
            second  = dt.getSeconds();
152
        }
153
    } else {
154
        /* Moving in calendar */
155
        if (month > 11) {
156
            month = 0;
157
            year++;
158
        }
159
        if (month < 0) {
160
            month = 11;
161
            year--;
162
        }
163
    }
164
165
    if (document.getElementById) {
166
        cnt = document.getElementById("calendar_data");
0 ignored issues
show
Bug introduced by
The variable cnt seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.cnt.
Loading history...
167
    } else if (document.all) {
168
        cnt = document.all["calendar_data"];
169
    }
170
171
    cnt.innerHTML = "";
0 ignored issues
show
Bug introduced by
The variable cnt does not seem to be initialized in case document.all on line 167 is false. Are you sure this can never be the case?
Loading history...
172
173
    str = ""
0 ignored issues
show
Bug introduced by
The variable str seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.str.
Loading history...
174
175
    //heading table
176
    str += '<table class="calendar"><tr><th width="50%">';
177
    str += '<form method="NONE" onsubmit="return 0">';
178
    str += '<a href="javascript:month--; initCalendar();">&laquo;</a> ';
179
    str += '<select id="select_month" name="monthsel" onchange="month = parseInt(document.getElementById(\'select_month\').value); initCalendar();">';
180
    for (i =0; i < 12; i++) {
0 ignored issues
show
Bug introduced by
The variable i seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.i.
Loading history...
181
        if (i == month) selected = ' selected="selected"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
The variable selected seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.selected.
Loading history...
182
        else selected = '';
183
        str += '<option value="' + i + '" ' + selected + '>' + month_names[i] + '</option>';
0 ignored issues
show
Bug introduced by
The variable month_names seems to be never declared. If this is a global, consider adding a /** global: month_names */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
184
    }
185
    str += '</select>';
186
    str += ' <a href="javascript:month++; initCalendar();">&raquo;</a>';
187
    str += '</form>';
188
    str += '</th><th width="50%">';
189
    str += '<form method="NONE" onsubmit="return 0">';
190
    str += '<a href="javascript:year--; initCalendar();">&laquo;</a> ';
191
    str += '<select id="select_year" name="yearsel" onchange="year = parseInt(document.getElementById(\'select_year\').value); initCalendar();">';
192
    for (i = year - 25; i < year + 25; i++) {
193
        if (i == year) selected = ' selected="selected"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
194
        else selected = '';
195
        str += '<option value="' + i + '" ' + selected + '>' + i + '</option>';
196
    }
197
    str += '</select>';
198
    str += ' <a href="javascript:year++; initCalendar();">&raquo;</a>';
199
    str += '</form>';
200
    str += '</th></tr></table>';
201
202
    str += '<table class="calendar"><tr>';
203
    for (i = 0; i < 7; i++) {
204
        str += "<th>" + day_names[i] + "</th>";
0 ignored issues
show
Bug introduced by
The variable day_names seems to be never declared. If this is a global, consider adding a /** global: day_names */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
205
    }
206
    str += "</tr>";
207
208
    var firstDay = new Date(year, month, 1).getDay();
209
    var lastDay = new Date(year, month + 1, 0).getDate();
210
211
    str += "<tr>";
212
213
    dayInWeek = 0;
0 ignored issues
show
Bug introduced by
The variable dayInWeek seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dayInWeek.
Loading history...
214
    for (i = 0; i < firstDay; i++) {
215
        str += "<td>&nbsp;</td>";
216
        dayInWeek++;
217
    }
218
    for (i = 1; i <= lastDay; i++) {
219
        if (dayInWeek == 7) {
220
            str += "</tr><tr>";
221
            dayInWeek = 0;
222
        }
223
224
        dispmonth = 1 + month;
0 ignored issues
show
Bug introduced by
The variable dispmonth seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dispmonth.
Loading history...
225
226
        if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
227
            actVal = "" + formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day');
0 ignored issues
show
Bug introduced by
The variable actVal seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.actVal.
Loading history...
228
        } else {
229
            actVal = "" + formatNum4(year) + formatNum2(dispmonth, 'month') + formatNum2(i, 'day');
230
        }
231
        if (i == day) {
232
            style = ' class="selected"';
0 ignored issues
show
Bug introduced by
The variable style seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.style.
Loading history...
233
            current_date = actVal;
0 ignored issues
show
Bug introduced by
The variable current_date seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.current_date.
Loading history...
234
        } else {
235
            style = '';
236
        }
237
        str += "<td" + style + "><a href=\"javascript:returnDate('" + actVal + "');\">" + i + "</a></td>"
238
        dayInWeek++;
239
    }
240
    for (i = dayInWeek; i < 7; i++) {
241
        str += "<td>&nbsp;</td>";
242
    }
243
244
    str += "</tr></table>";
245
246
    cnt.innerHTML = str;
247
248
    // Should we handle time also?
249
    if (window.opener.dateType != 'date' && !clock_set) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable clock_set is declared in the current environment, consider using typeof clock_set === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
250
251
        if (document.getElementById) {
252
            cnt = document.getElementById("clock_data");
253
        } else if (document.all) {
254
            cnt = document.all["clock_data"];
255
        }
256
257
        str = '';
258
        init_hour = hour;
0 ignored issues
show
Bug introduced by
The variable init_hour seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.init_hour.
Loading history...
259
        init_minute = minute;
0 ignored issues
show
Bug introduced by
The variable init_minute seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.init_minute.
Loading history...
260
        init_second = second;
0 ignored issues
show
Bug introduced by
The variable init_second seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.init_second.
Loading history...
261
        str += '<fieldset>';
262
        str += '<form method="NONE" class="clock" onsubmit="returnDate(\'' + current_date + '\')">';
0 ignored issues
show
Bug introduced by
The variable current_date seems to not be initialized for all possible execution paths.
Loading history...
263
        str += '<input id="hour"    type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_hour, \'hour\'); init_hour = this.value;" value="' + formatNum2(hour, 'hour') + '" />:';
264
        str += '<input id="minute"  type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_minute, \'minute\'); init_minute = this.value;" value="' + formatNum2(minute, 'minute') + '" />:';
265
        str += '<input id="second"  type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_second, \'second\'); init_second = this.value;" value="' + formatNum2(second, 'second') + '" />';
266
        str += '&nbsp;&nbsp;';
267
        str += '<input type="submit" value="' + submit_text + '"/>';
0 ignored issues
show
Bug introduced by
The variable submit_text seems to be never declared. If this is a global, consider adding a /** global: submit_text */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
268
        str += '</form>';
269
        str += '</fieldset>';
270
271
        cnt.innerHTML = str;
272
        clock_set = 1;
0 ignored issues
show
Bug introduced by
The variable clock_set seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.clock_set.
Loading history...
273
    }
274
275
}
276
277
/**
278
 * Returns date from calendar.
279
 *
280
 * @param   string     date text
0 ignored issues
show
Documentation introduced by
The parameter string does not exist. Did you maybe forget to remove this comment?
Loading history...
281
 */
282
function returnDate(d) {
283
    txt = d;
0 ignored issues
show
Bug introduced by
The variable txt seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.txt.
Loading history...
284
    if (window.opener.dateType != 'date') {
285
        // need to get time
286
        h = parseInt(document.getElementById('hour').value,10);
0 ignored issues
show
Bug introduced by
The variable h seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.h.
Loading history...
287
        m = parseInt(document.getElementById('minute').value,10);
0 ignored issues
show
Bug introduced by
The variable m seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.m.
Loading history...
288
        s = parseInt(document.getElementById('second').value,10);
0 ignored issues
show
Bug introduced by
The variable s seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.s.
Loading history...
289
        if (window.opener.dateType == 'datetime') {
290
            txt += ' ' + formatNum2(h, 'hour') + ':' + formatNum2(m, 'minute') + ':' + formatNum2(s, 'second');
291
        } else {
292
            // timestamp
293
            txt += formatNum2(h, 'hour') + formatNum2(m, 'minute') + formatNum2(s, 'second');
294
        }
295
    }
296
297
    window.opener.dateField.value = txt;
298
    window.close();
299
}
300
301
302
303
//-------------------------------------------------
304
function getE(id)
305
{
306
   if (typeof id != "string")
307
   {
308
         return id;
309
   }
310
   else if (Boolean(document.getElementById))
311
   {
312
         return document.getElementById(id);
313
   }
314
   else if (Boolean(document.all))
315
   {
316
         return eval("document.all."+id);
0 ignored issues
show
Security Performance introduced by
Calls to eval are slow and potentially dangerous, especially on untrusted code. Please consider whether there is another way to achieve your goal.
Loading history...
317
   }
318
   else if (Boolean(document.ids))
319
   {
320
         return eval("document.ids."+id);
0 ignored issues
show
Security Performance introduced by
Calls to eval are slow and potentially dangerous, especially on untrusted code. Please consider whether there is another way to achieve your goal.
Loading history...
321
   }
322
   else
323
   {
324
         return null;
325
   }
326
}
327
//-------------------------------------------------
328
function okno(action,winwidth,winheight,name,scroll,toolbar,status,resizable,menubar) {
329
	var PROFILE = null;
0 ignored issues
show
Unused Code introduced by
The assignment to PROFILE seems to be never used. If you intend to free memory here, this is not necessary since the variable leaves the scope anyway.
Loading history...
330
       
331
	PROFILE =  window.open ("", name, "toolbar="+toolbar+",width="+winwidth+",height="+winheight+",directories=no,location=no,status="+status+",scrollbars="+scroll+",resizable="+resizable+",menubar="+menubar+"");
332
        if (PROFILE != null) {
333
               if (PROFILE.opener == null) {
334
                   PROFILE.opener = self;
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
335
        	   }
336
	       PROFILE.location.href = action;
337
        } 
338
       
339
       
340
}
341
//-------------------------------------------------
342
function reokno(action,winwidth,winheight,name,scroll,toolbar,status,resize,menubar) 
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
343
	{
344
	
345
	window.close();
346
	
347
	b = window.opener;
0 ignored issues
show
Bug introduced by
The variable b seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.b.
Loading history...
348
	a = b.closed;
0 ignored issues
show
Bug introduced by
The variable a seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.a.
Loading history...
349
				
350
	if (!a)
351
	{
352
		var PROFILE = null;
0 ignored issues
show
Unused Code introduced by
The assignment to PROFILE seems to be never used. If you intend to free memory here, this is not necessary since the variable leaves the scope anyway.
Loading history...
353
	       	PROFILE =  self.open ("", "nalezen", "toolbar="+toolbar+",width="+winwidth+",height="+winheight+",directories=no, status="+status+",scrollbars="+scroll+",resize="+resize+",menubar="+menubar+"");
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
354
	        if (PROFILE != null) {
355
	               if (PROFILE.opener == null) {
356
	                   PROFILE.opener = self;
357
	        	   }
358
		       PROFILE.location.href = action;
359
	}
360
        }
361
}
362
//-------------------------------------------------
363
function reoknoclen(action,winwidth,winheight,name,scroll,toolbar,status,resize,menubar) 
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
364
	{
365
	
366
	window.close();
367
	
368
	b = window.opener;
0 ignored issues
show
Bug introduced by
The variable b seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.b.
Loading history...
369
	a = b.closed;
0 ignored issues
show
Bug introduced by
The variable a seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.a.
Loading history...
370
				
371
	if (!a)
372
	{
373
		var PROFILE = null;
0 ignored issues
show
Unused Code introduced by
The assignment to PROFILE seems to be never used. If you intend to free memory here, this is not necessary since the variable leaves the scope anyway.
Loading history...
374
	       	PROFILE =  self.open ("", "clen", "toolbar="+toolbar+",width="+winwidth+",height="+winheight+",directories=no, status="+status+",scrollbars="+scroll+",resize="+resize+",menubar="+menubar+"");
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
375
	        if (PROFILE != null) {
376
	               if (PROFILE.opener == null) {
377
	                   PROFILE.opener = self;
378
	        	   }
379
		       PROFILE.location.href = action;
380
	}
381
        }
382
        }
383
//-------------------------------------------------
384
function GetElementById(id){
385
	if (document.getElementById) {
386
		return (document.getElementById(id));
387
	} else if (document.all) {
388
		return (document.all[id]);
389
	} else {
390
		if ((navigator.appname.indexOf("Netscape") != -1) && parseInt(navigator.appversion == 4)) {
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Complexity Best Practice introduced by
There is no return statement if navigator.appname.indexO...igator.appversion == 4) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
391
			return (document.layers[id]);
392
		}
393
	}
394
}
395
//-------------------------------------------------
396
function CheckAll(formname, switchid) {
397
	var ele = document.forms[formname].elements;
398
	var switch_cbox = GetElementById(switchid);
399
	for (var i = 0; i < ele.length; i++) {
400
		var e = ele[i];
401
		if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) {
402
			e.checked = switch_cbox.checked;
403
		}
404
	}
405
}
406
//-------------------------------------------------
407
function stylTextu(formname, policko, styl) {
408
if(styl == "a")
409
{
410
	var adresa = prompt('Zadej adresu odkazu', '');
411
	var text = prompt('Zadej název odkazu', '');
412
	document.forms[formname].elements[policko].value += "<"+ styl +" href=\""+ adresa +"\">"+ text +"</"+ styl +">";
413
}
414
else
415
{
416
	var text = prompt('Zadej text', '');
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable text already seems to be declared on line 411. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
417
	document.forms[formname].elements[policko].value += "<"+ styl +">"+ text +"</"+ styl +">";
418
}
419
}
420
//-------------------------------------------------
421
function anketa_check_form(formname,moznost) {
422
	var ele = formname.moznost;
423
var chyba = "Nevybrali jste žádnou možnost!";
424
		for (var i = 0; i < ele.length; i++) {
425
			var e = ele[i];
426
			if (e.checked == true){
427
			var chyba = "";
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable chyba already seems to be declared on line 423. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
428
			}
429
		}
430
		if (chyba != ""){
431
			alert (chyba);
432
			return false;
433
		}
434
		else return true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
435
}
436
//-------------------------------------------------
437
function confirmation(adresa, hlaska) 
438
          {
439
          var potvrdit = confirm (hlaska);
440
          if (potvrdit)
441
               {
442
               //self.location.href = adresa;
443
			   window.location.replace(adresa);
444
			   }
445
	     }
446
//-------------------------------------------------
447
function validate_email(field, alerttxt)
448
		{
449
			with (field){
0 ignored issues
show
Comprehensibility Compatibility Best Practice introduced by
The use of the with statement is discouraged as it makes your code harder to understand and may not be forward compatible with newer versions of javascript.
Loading history...
450
				apos=value.indexOf("@");
451
				dotpos=value.lastIndexOf(".");
452
				if (apos<1||dotpos-apos<2){
453
					alert(alerttxt);
454
					return false;
455
				}
456
				else {return true;}
457
			}
458
		}
459
//-------------------------------------------------
460
function validate_empty(field, alerttxt)
461
		{
462
			with (field){
0 ignored issues
show
Comprehensibility Compatibility Best Practice introduced by
The use of the with statement is discouraged as it makes your code harder to understand and may not be forward compatible with newer versions of javascript.
Loading history...
463
				if (value == ""){
464
					alert(alerttxt);
465
					return false;
466
				}
467
				else {return true;}
468
			}
469
		}
470
//-------------------------------------------------
471
function UkazHide(div,stav)
472
{
473
   var d = getE(div);
474
   var _stav = stav;
475
476
   if (d == null) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
477
478
   if (stav == 3)
479
   {
480
         if (d.style.display == "") _stav = 0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
481
         else                       _stav = 1;
482
   }
483
484
   if (_stav == 0)
485
   {
486
         d.style.visibility = "hidden";
487
         d.style.display    = "none";
488
   }
489
   else
490
   {
491
         d.style.visibility = "visible";
492
         d.style.display    = "";
493
   }
494
}
495
//-------------------------------------------------
496
function ZmenSelect(ele,value)
497
{
498
   var d = getE(ele);
499
   var v = value;
500
   d.selectedIndex = v;
501
}
502
/*
503
function checkAllCheckboxes(field)
504
{
505
	for (i = 0; i < field.length; i++)
506
		field[i].checked = true ;
507
}
508
509
function uncheckAllCheckboxes(field)
510
{
511
	for (i = 0; i < field.length; i++)
512
		field[i].checked = false ;
513
}
514
515
function checkAll(theForm)
516
{
517
	for (i=0;i<theForm.elements.length;i++)
518
		if (theForm.elements[i].name.indexOf('checker') !=-1)
519
		theForm.elements[i].checked = true;
520
}
521
522
function uncheckAll(theForm)
523
{
524
	for (i=0;i<theForm.elements.length;i++)
525
		if (theForm.elements[i].name.indexOf('checker') !=-1)
526
		theForm.elements[i].checked = false;
527
}*/
528
529
function select(boolean) {
530
	var theForm = document.checkerForm;
531
	for (i=0; i<theForm.elements.length; i++) {
0 ignored issues
show
Bug introduced by
The variable i seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.i.
Loading history...
532
		if (theForm.elements[i].name=='checker[]')
533
		theForm.elements[i].checked = boolean;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
534
	}
535
}